package com.yyjj.zixun.activity;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.vise.xsnow.http.mode.CacheMode;
import com.yyjj.zixun.R;
import com.yyjj.zixun.adapter.GanTouAdapter;
import com.yyjj.zixun.adapter.HomeNewsListAdapter;
import com.yyjj.zixun.api.Api;
import com.yyjj.zixun.entity.BaseGHResp;
import com.yyjj.zixun.entity.GtDataResp;
import com.yyjj.zixun.entity.HomeNewsListEntity;
import com.yyjj.zixun.entity.TouJiaoGanHuoEntity;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseRefreshLoadActivity;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.entity.BaseTResp;
import tech.com.commoncore.view.SpaceItemDecoration;

@Route(path = "/zixun/BaiKe")
public class BaiKeActivity extends BaseRefreshLoadActivity<HomeNewsListEntity> {

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText("基金百科");
    }

    @Override
    public int getContentLayout() {
        return R.layout.zixun_caijing_zixun;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        mRecyclerView.addItemDecoration(new SpaceItemDecoration(1));

    }

    @Override
    public BaseQuickAdapter getAdapter() {
        return new GanTouAdapter(R.layout.zixun_item_gantou_list);
    }

    @Override
    public void loadData(int page) {
        ViseHttp.GET(Api.GANHUO_URL)
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("page",  1 + "")
                .addParam("pagesize", 10 + "")
                .addParam("order", "id")
                .addParam("category", "213")
                .request(new ACallback<BaseGHResp<GtDataResp<ArrayList<TouJiaoGanHuoEntity>>>>() {

                    @Override
                    public void onSuccess(BaseGHResp<GtDataResp<ArrayList<TouJiaoGanHuoEntity>>> data) {
                        if ((1 == data.code) && (data.data != null)) {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), data.data.data, null);
                        }
                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
                        FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                    }
                });
    }
}
